package com.xbk.seckill.activity.application.service.fallback;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.xbk.seckill.common.model.dto.SeckillActivityDTO;
import com.xbk.seckill.common.model.enums.SeckillActivityStatus;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author xiexu
 * @date 2025/5/11 16:09
 */
@Slf4j
@Component
public class SeckillActivityFallbackService {

    public static SeckillActivityDTO getSeckillActivityBlockHandler(Long id, Long version, BlockException e) {
        log.info("getSeckillActivityBlockHandler|处理lockHandler|{},{},{}",id, version, e.getMessage());
        Date date = new Date();
        return new SeckillActivityDTO(-1001L, "BlockHandler活动", date, date, SeckillActivityStatus.OFFLINE.getCode(), "BlockHandler活动", 0L);
    }

    public static SeckillActivityDTO getSeckillActivityFallback(Long id, Long version, Throwable t) {
        log.info("getSeckillActivityBlockHandler|处理Fallback|{},{},{}", id, version, t.getMessage());
        Date date = new Date();
        return new SeckillActivityDTO(-1001L, "Fallback活动", date, date, SeckillActivityStatus.OFFLINE.getCode(), "Fallback活动", 0L);
    }

}
